package in.muton.edushare.components.alertpanel.api;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.wicket.model.IModel;

import com.edushare.common.vo.Assignments;
import com.edushare.common.vo.DateComparision;
import com.edushare.common.vo.UserAssignmentLink;
import com.edushare.common.vo.Users;

public class AssgnAlertMgr {

	private static final long serialVersionUID = -3213226296157215282L;

	public AssgnAlertMgr(IModel<Users> model) {
		this.model = model;
	}

	List<DateComparision> getAssignments() {
		List<UserAssignmentLink> links = model.getObject().getAssignmentLink();
		List<DateComparision> sortedLinks = new ArrayList<DateComparision>();

		for (UserAssignmentLink l : links) {
			if (	l.getStatus() == UserAssignmentLink.STATUS_SUBMISSION_PENDING && 
					l.getAssignment().getStatus() != Assignments.ASSIGNMENT_STATUS_CLOSED &&
					l.getShowAlert() != UserAssignmentLink.ALERT_DONT_SHOW &&
					l.getDate().getTime() >  new Date().getTime()) {
				sortedLinks.add(l);
			}
		}
		return sortedLinks;
	}

	private IModel<Users> model = null;
}
